Repository navigation
feat(cloudflare/workers): worker versions and gradual deployments - #948
Merged
Merged
Conversation
Adds a version prop to Cloudflare.Worker mapping Cloudflare's versions and gradual deployments onto alchemy stages: - version.parent uploads this Worker as an immutable version of another Worker's script (PR previews via preview URL, canaries via traffic) - version.traffic on a self-owned Worker deploys gradually, splitting traffic between the new and previously-live version Includes distilled patch typing createScriptVersion's binding-validation errors (alchemy-run/distilled#389). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/440777c@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/440777c@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/440777c |
Resolves Worker.ts / WorkerProvider.ts conflicts (Worker.URL #964 landed alongside the version prop) and rejects Worker.URL bindings on version workers — a version's URL is its preview URL, which only exists after upload. Distilled submodule resolves to main's pointer, which already contains distilled#389. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n workers A version's per-version preview URL derives from the server-assigned version id, so it can never be baked into the version's own bindings. Aliased preview URLs break the cycle: the alias is deterministic before upload, so the URL is knowable ahead of time and stable across deploys. - Auto-derive a stable alias per (stack, stage, id) for version workers; override with version.alias. url = aliased preview URL; the per-version URL rides in domains. - Worker.URL (self_url) now lowers into the aliased URL on version workers instead of being rejected; typed error remains when previews are disabled or no alias fits the 63-char DNS label. - New versionAlias attribute; alias annotation (workers/alias) sent on version uploads, pass-through on self-rollouts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sam-goodwin
added a commit
that referenced
this pull request
Jul 28, 2026
- resolveWorkerDomain accepts the pre-redesign domain: string[] prop shape from persisted olds (first hostname = name, rest = aliases, [] = detach-all) instead of degrading to a bogus 'undefined' hostname - unit coverage for resolveWorkerDomain (shorthand, punycode/dedupe, legacy array, null, role-overlap error) and stateWorkerDomain (all state generations) - live test: props-identical redeploy migrates a #948-era version worker record (preview URLs in domains, no urls) as a one-time update that keeps the aliased preview URL byte-stable and settles to noop Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
versionprop toCloudflare.Workermapping Cloudflare's versions & gradual deployments onto alchemy stages.parentaccepts a Worker ref (yield* Worker.ref(id, { stage, stack })), a locally-declared Worker, or a literal script name as an escape hatch. Changing parent (or mode) replaces the resource.urlis its aliased preview URL (<alias>-<name>.<subdomain>.workers.dev): the alias is auto-derived per (stack, stage, id) — override withversion.alias— so the link is stable across deploys and re-points at each newly uploaded version. The per-version URL rides indomains. Because the aliased URL is known before upload,Worker.URLworks on version workers and resolves to it (typed error when previews are disabled or no alias fits the 63-char DNS label).readverifies the version exists on the parent (never adopts the parent's script),deleterestores 100% of traffic to the surviving version and leaves the parent untouched,precreateskips the placeholder script.routes,domain,crons,tags,observability,logpush,placement,limits,subdomain,assets,name,namespace) are rejected on version workers with a typedWorkerVersionConfigError, as are locally-hosted Durable Object / Workflow classes (their migrations would mutate the parent).createScriptVersion+createScriptDeploymentinstead of the full-cutoverputScript; the first deploy of a script always goes to 100%. Assets and pending DO migrations can't ride a rollout (typed error).versionOf,versionId,deploymentId. The metadata hash reducesversion.parentto the parent's script name so parent redeploys don't spuriously re-version children.Includes alchemy-run/distilled#389 (typed binding-validation errors on
createScriptVersion) — already merged upstream; the distilled submodule points at distilled main, which contains it.Live-tested in
test/Cloudflare/Workers/WorkerVersion.test.ts: preview URL serves the version's code while the parent's deployment is untouched, aliased URL stable across the preview→canary redeploy, canary split asserted at 25/75 out-of-band vialistScriptDeployments, canary removal restores 100%, string-name parent, rollout 100 → 50/50 → 100,Worker.URLon a version echoing its own aliased URL, and the validation error.Worker.test.tspasses unchanged.Docs:
Versions & Gradual DeploymentsJSDoc section on the Worker resource plus a new section in the Workers guide.🤖 Generated with Claude Code